<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="UTF-8">
  <meta 
    name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <meta 
    http-equiv="X-UA-Compatible" 
    content="ie=edge">
  <meta 
    name="theme-color" 
    content="#fff" 
    id="theme-color">
  <meta 
    name="description" 
    content="Hexo">
  <link 
    rel="icon" 
    href="https://demo.theme-kaze.top/img/Kaze.png">
  <title>openresty测试广告图片的载入与读取.md</title>
  
    
      <meta 
        property="og:title" 
        content="openresty测试广告图片的载入与读取.md">
    
    
      <meta 
        property="og:url" 
        content="https://laoma.gitee.io/fungloengblog/2020/07/28/openresty%E6%B5%8B%E8%AF%95%E5%B9%BF%E5%91%8A%E5%9B%BE%E7%89%87%E7%9A%84%E8%BD%BD%E5%85%A5%E4%B8%8E%E8%AF%BB%E5%8F%96/index.html">
    
    
      <meta 
        property="og:img" 
        content="https://demo.theme-kaze.top/img/Kaze.png">
    
    
    
      <meta 
        property="og:type" 
        content="article">
      <meta 
        property="og:article:published_time" 
        content="2020-07-28">
      <meta 
        property="og:article:modified_time" 
        content="2021-12-21">
      <meta 
        property="og:article:author" 
        content="IAMFUNGLOENG">
      
        
          <meta 
            property="og:article:tag" 
            content="openresty">
        
          <meta 
            property="og:article:tag" 
            content="lua">
        
          <meta 
            property="og:article:tag" 
            content="nginx">
        
      
    
  
  <script>
    function loadScript(url, cb) {
      var script = document.createElement('script');
      script.src = url;
      if (cb) script.onload = cb;
      script.async = true;
      document.body.appendChild(script);
    }
    function loadCSS(href, data, attr) {
      var sheet = document.createElement('link');
      sheet.ref = 'stylesheet';
      sheet.href = href;
      sheet.dataset[data] = attr;
      document.head.appendChild(sheet);
    }
    function changeCSS(cssFile, data, attr) {
      var oldlink = document.querySelector(data);
      var newlink = document.createElement("link");
      newlink.setAttribute("rel", "stylesheet");
      newlink.setAttribute("href", cssFile);
      newlink.dataset.prism = attr;
      document.head.replaceChild(newlink, oldlink);
    }
  </script>
  
    
  
  <script>
    // control reverse button
    var reverseDarkList = {
      dark: 'light',
      light: 'dark'
    };
    var themeColor = {
      dark: '#1c1c1e',
      light: '#fff'
    }
    // get the data of css prefers-color-scheme
    var getCssMediaQuery = function() {
      return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
    };
    // reverse current darkmode setting function
    var reverseDarkModeSetting = function() {
      var setting = localStorage.getItem('user-color-scheme');
      if(reverseDarkList[setting]) {
        setting = reverseDarkList[setting];
      } else if(setting === null) {
        setting = reverseDarkList[getCssMediaQuery()];
      } else {
        return;
      }
      localStorage.setItem('user-color-scheme', setting);
      return setting;
    };
    // apply current darkmode setting
  </script>
  
    <script>
      var setDarkmode = function(mode) {
      var setting = mode || localStorage.getItem('user-color-scheme');
      if(setting === getCssMediaQuery()) {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else if(reverseDarkList[setting]) {
        document.documentElement.setAttribute('data-user-color-scheme', setting);
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
        document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
      }
    };
    setDarkmode();
    </script>
  
  
  <link rel="preload" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css" as="style" >
  <link rel="preload" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css" as="style" >
  
  
    <link rel="preload" href="/fungloengblog/js/lib/lightbox/baguetteBox.min.js" as="script">
    <link rel="preload" href="/fungloengblog/js/lib/lightbox/baguetteBox.min.css" as="style" >
  
  
    <link rel="preload" href="/fungloengblog/js/lib/lozad.min.js" as="script">
  
  
  
  
  
  
  
  <link rel="stylesheet" href="/fungloengblog/css/main.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css">
  
    <link rel="stylesheet" href="/fungloengblog/js/lib/lightbox/baguetteBox.min.css">
  
<meta name="generator" content="Hexo 5.4.0"></head>

  <body>
    <div class="wrapper">
       
      <nav class="navbar">
  <div class="navbar-logo">
    <span class="navbar-logo-main">
      
        <img 
          class="navbar-logo-img"
          width="32"
          height="32"
          src="https://demo.theme-kaze.top/img/Kaze.png" 
          alt="blog logo">
      
      <span class="navbar-logo-dsc">FUNGLOENG</span>
    </span>
  </div>
  <div class="navbar-menu">
    
      <a 
        href="/fungloengblog/" 
        class="navbar-menu-item">
        
          首页
        
      </a>
    
      <a 
        href="/fungloengblog/archives" 
        class="navbar-menu-item">
        
          归档
        
      </a>
    
      <a 
        href="/fungloengblog/tags" 
        class="navbar-menu-item">
        
          标签
        
      </a>
    
      <a 
        href="/fungloengblog/categories" 
        class="navbar-menu-item">
        
          分类
        
      </a>
    
      <a 
        href="/fungloengblog/about" 
        class="navbar-menu-item">
        
          关于
        
      </a>
    
      <a 
        href="/fungloengblog/links" 
        class="navbar-menu-item">
        
          友链
        
      </a>
    
    <a 
      class="navbar-menu-item darknavbar" 
      id="dark">
      <i class="iconfont icon-weather"></i>
    </a>
    <a 
      class="navbar-menu-item searchnavbar" 
      id="search">
      <i 
        class="iconfont icon-search" 
        style="font-size: 1.2rem; font-weight: 400;">
      </i>
    </a>
  </div>
</nav> 
      
      <div 
        id="local-search" 
        style="display: none">
        <input
          class="navbar-menu-item"
          id="search-input"
          placeholder="请输入搜索内容..." />
        <div id="search-content"></div>
      </div>
      
      <div class="section-wrap">
        <div class="container">
          <div class="columns">
            <main class="main-column">
<article class="card card-content">
  <header>
    <h1 class="post-title">
      openresty测试广告图片的载入与读取.md
    </h1>
  </header>
  <div class="post-meta post-show-meta">
    <time datetime="2020-07-28T13:05:44.000Z">
      <i 
        class="iconfont icon-calendar" 
        style="margin-right: 2px;">
      </i>
      <span>2020-07-28</span>
    </time>
    
    
      <span class="dot"></span>
      <span>251 字</span>
    
  </div>
  
    <div 
      class="post-meta post-show-meta" 
      style="margin-top: -10px;">
      <div style="display: flex; align-items: center;">
        <i 
          class="iconfont icon-biaoqian" 
          style="margin-right: 2px; font-size: 1.15rem;">
        </i>
        
          
          <a 
            href="/fungloengblog/tags/openresty/" 
            class="post-meta-link">
            openresty
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/fungloengblog/tags/lua/" 
            class="post-meta-link">
            lua
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/fungloengblog/tags/nginx/" 
            class="post-meta-link">
            nginx
          </a>
        
      </div>
    </div>
  
  </header>
  <div 
    id="section" 
    class="post-content">
    <h6 id="1-创建目录-并在该目录下创建update-content-lua文件，目的是连接mysql数据库查询数据并存储到redis中"><a href="#1-创建目录-并在该目录下创建update-content-lua文件，目的是连接mysql数据库查询数据并存储到redis中" class="headerlink" title="1. 创建目录,并在该目录下创建update_content.lua文件，目的是连接mysql数据库查询数据并存储到redis中"></a>1. 创建目录,并在该目录下创建update_content.lua文件，目的是连接mysql数据库查询数据并存储到redis中</h6><pre class="highlight"><span class="line">mkdir /home/laoma/lua</span><br><span class="line"><span class="built_in">cd</span> lua</span><br><span class="line">vi update_content.lua</span><br></pre>

<p>update_content.lua文件内容：</p>
<pre class="highlight"><span class="line">ngx.header.content_type=<span class="string">&quot;application/json;charset=utf8&quot;</span></span><br><span class="line"><span class="keyword">local</span> cjson = <span class="built_in">require</span>(<span class="string">&quot;cjson&quot;</span>)</span><br><span class="line"><span class="keyword">local</span> mysql = <span class="built_in">require</span>(<span class="string">&quot;resty.mysql&quot;</span>)</span><br><span class="line"><span class="keyword">local</span> uri_args = ngx.req.get_uri_args()</span><br><span class="line"><span class="keyword">local</span> id = uri_args[<span class="string">&quot;id&quot;</span>]</span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> db = mysql:new()</span><br><span class="line">db:set_timeout(<span class="number">1000</span>)</span><br><span class="line"><span class="keyword">local</span> props = &#123;</span><br><span class="line">    host = <span class="string">&quot;127.0.0.1&quot;</span>,</span><br><span class="line">    port = <span class="number">3306</span>,</span><br><span class="line">    database = <span class="string">&quot;loengmall_content&quot;</span>,</span><br><span class="line">    user = <span class="string">&quot;root&quot;</span>,</span><br><span class="line">    password = <span class="string">&quot;******&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> res = db:connect(props)</span><br><span class="line"><span class="keyword">local</span> select_sql = <span class="string">&quot;select url,pic from tb_content where status =&#x27;1&#x27; and category_id=&quot;</span>..id..<span class="string">&quot; order by sort_order&quot;</span></span><br><span class="line">res = db:query(select_sql)</span><br><span class="line">db:<span class="built_in">close</span>()</span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> redis = <span class="built_in">require</span>(<span class="string">&quot;resty.redis&quot;</span>)</span><br><span class="line"><span class="keyword">local</span> red = redis:new()</span><br><span class="line">red:set_timeout(<span class="number">2000</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> ip =<span class="string">&quot;127.0.0.1&quot;</span></span><br><span class="line"><span class="keyword">local</span> port = <span class="number">6379</span></span><br><span class="line">red:connect(ip,port)</span><br><span class="line">red:set(<span class="string">&quot;content_&quot;</span>..id,cjson.encode(res))</span><br><span class="line">red:<span class="built_in">close</span>()</span><br><span class="line"></span><br><span class="line">ngx.say(<span class="string">&quot;&#123;flag:true&#125;&quot;</span>)</span><br></pre>

<h6 id="2-修改-usr-local-openresty-nginx-conf-nginx-conf文件，添加头信息和location信息"><a href="#2-修改-usr-local-openresty-nginx-conf-nginx-conf文件，添加头信息和location信息" class="headerlink" title="2. 修改/usr/local/openresty/nginx/conf/nginx.conf文件，添加头信息和location信息"></a>2. 修改/usr/local/openresty/nginx/conf/nginx.conf文件，添加头信息和location信息</h6><pre class="highlight"><span class="line"><span class="attr">server</span> <span class="string">&#123;</span></span><br><span class="line">       <span class="attr">listen</span>       <span class="string">80;</span></span><br><span class="line">       <span class="attr">server_name</span>  <span class="string">localhost;</span></span><br><span class="line"></span><br><span class="line">       <span class="attr">location</span> <span class="string">/update_content &#123;</span></span><br><span class="line">               <span class="attr">content_by_lua_file</span> <span class="string">/home/laoma/lua/update_content.lua;</span></span><br><span class="line">       <span class="attr">&#125;</span></span><br><span class="line"> <span class="attr">&#125;</span></span><br></pre>

<p>切换到/sbin目录下，重启nginx，命令如下：</p>
<pre class="highlight"><span class="line"><span class="built_in">cd</span> /usr/local/openresty/nginx/sbin</span><br><span class="line">sudo ./nginx <span class="literal">-s</span> reload</span><br></pre>




  </div>
  <div>
    
      <div 
        class="post-note note-warning copyright" 
        style="margin-top: 42px">
        <p>
          <span style="font-weight: bold;">作者：</span><a 
            target="_blank" 
            rel="nofollow noopener noreferrer" 
            href="/fungloengblog/about">
            IAMFUNGLOENG
          </a>
        </p>
        <p>
          <span style="font-weight: bold;">文章链接：</span><a 
            target="_blank" 
            rel="nofollow noopener noreferrer" 
            href="https://laoma.gitee.io/fungloengblog/2020/07/28/openresty%E6%B5%8B%E8%AF%95%E5%B9%BF%E5%91%8A%E5%9B%BE%E7%89%87%E7%9A%84%E8%BD%BD%E5%85%A5%E4%B8%8E%E8%AF%BB%E5%8F%96/">
            https://laoma.gitee.io/fungloengblog/2020/07/28/openresty%E6%B5%8B%E8%AF%95%E5%B9%BF%E5%91%8A%E5%9B%BE%E7%89%87%E7%9A%84%E8%BD%BD%E5%85%A5%E4%B8%8E%E8%AF%BB%E5%8F%96/
          </a>
        </p>
        <p><span style="font-weight: bold;">版权声明：</span>本博客所有文章除特别声明外，均采用<a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0 协议</a>。转载请注明出处！</p>
      </div>
    
  </div>
</article>
<div class="nav">
  
    <div class="nav-item-prev">
      <a 
        href="/fungloengblog/2020/07/28/docker%E8%BF%90%E8%A1%8Credis/" 
        class="nav-link">
        <i class="iconfont icon-left nav-prev-icon"></i>
        <div>
          <div class="nav-label">上一篇</div>
          
            <div class="nav-title">docker运行redis.md </div>
          
        </div>
      </a>
    </div>
  
  
    <div class="nav-item-next">
      <a 
        href="/fungloengblog/2020/07/26/win10-wsl2%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%9B%BE%E5%BD%A2%E7%95%8C%E9%9D%A2-GUI-/" 
        class="nav-link">
        <div>
          <div class="nav-label">下一篇</div>
          
            <div class="nav-title">win10 wsl2中使用图形界面(GUI).md </div>
          
        </div>
        <i class="iconfont icon-right nav-next-icon"></i>
      </a>
    </div>
  
</div>

<div 
  class="card card-content toc-card" 
  id="mobiletoc">
  <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95-%E5%B9%B6%E5%9C%A8%E8%AF%A5%E7%9B%AE%E5%BD%95%E4%B8%8B%E5%88%9B%E5%BB%BAupdate-content-lua%E6%96%87%E4%BB%B6%EF%BC%8C%E7%9B%AE%E7%9A%84%E6%98%AF%E8%BF%9E%E6%8E%A5mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%AD%98%E5%82%A8%E5%88%B0redis%E4%B8%AD"><span class="toc-text">1. 创建目录,并在该目录下创建update_content.lua文件，目的是连接mysql数据库查询数据并存储到redis中</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2-%E4%BF%AE%E6%94%B9-usr-local-openresty-nginx-conf-nginx-conf%E6%96%87%E4%BB%B6%EF%BC%8C%E6%B7%BB%E5%8A%A0%E5%A4%B4%E4%BF%A1%E6%81%AF%E5%92%8Clocation%E4%BF%A1%E6%81%AF"><span class="toc-text">2. 修改&#x2F;usr&#x2F;local&#x2F;openresty&#x2F;nginx&#x2F;conf&#x2F;nginx.conf文件，添加头信息和location信息</span></a></li></ol>
</div></main>
            <aside class="left-column">
              
              <div class="card card-author">
                
  <img 
    src="https://demo.theme-kaze.top/img/Kaze.png" 
    class="author-img"
    width="88"
    height="88"
    alt="author avatar">

<p class="author-name">IAMFUNGLOENG</p>
<p class="author-description">designed by fungloeng</p>
<div class="author-message">
  <a 
    class="author-posts-count" 
    href="/fungloengblog/archives">
    <span>27</span>
    <span>文章</span>
  </a>
  <a 
    class="author-categories-count" 
    href="/fungloengblog/categories">
    <span>8</span>
    <span>分类</span>
  </a>
  <a 
    class="author-tags-count" 
    href="/fungloengblog/tags">
    <span>20</span>
    <span>标签</span>
  </a>
</div>

              </div>
               <div class="sticky-tablet">
  
  
    <article class="display-when-two-columns spacer">
      <div class="card card-content toc-card">
        <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95-%E5%B9%B6%E5%9C%A8%E8%AF%A5%E7%9B%AE%E5%BD%95%E4%B8%8B%E5%88%9B%E5%BB%BAupdate-content-lua%E6%96%87%E4%BB%B6%EF%BC%8C%E7%9B%AE%E7%9A%84%E6%98%AF%E8%BF%9E%E6%8E%A5mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%AD%98%E5%82%A8%E5%88%B0redis%E4%B8%AD"><span class="toc-text">1. 创建目录,并在该目录下创建update_content.lua文件，目的是连接mysql数据库查询数据并存储到redis中</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2-%E4%BF%AE%E6%94%B9-usr-local-openresty-nginx-conf-nginx-conf%E6%96%87%E4%BB%B6%EF%BC%8C%E6%B7%BB%E5%8A%A0%E5%A4%B4%E4%BF%A1%E6%81%AF%E5%92%8Clocation%E4%BF%A1%E6%81%AF"><span class="toc-text">2. 修改&#x2F;usr&#x2F;local&#x2F;openresty&#x2F;nginx&#x2F;conf&#x2F;nginx.conf文件，添加头信息和location信息</span></a></li></ol>
      </div>
    </article>
  
  
  <article class="card card-content categories-widget">
    <div class="categories-card">
  <div class="categories-header">
    <i 
      class="iconfont icon-fenlei" 
      style="padding-right: 2px;">
    </i>分类
  </div>
  <div class="categories-list">
    
      <a href="/fungloengblog/categories/hexo/">
        <div class="categories-list-item">
          hexo
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/docker/">
        <div class="categories-list-item">
          docker
          <span class="categories-list-item-badge">2</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/docker/fastdfs/">
        <div class="categories-list-item">
          docker/fastdfs
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/docker/mysql/">
        <div class="categories-list-item">
          docker/mysql
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/idea/">
        <div class="categories-list-item">
          idea
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/idea/github/">
        <div class="categories-list-item">
          idea/github
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/win10/">
        <div class="categories-list-item">
          win10
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/fungloengblog/categories/win10/hyper-v/">
        <div class="categories-list-item">
          win10/hyper-v
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
  </div>
</div>
  </article>
  
  <article class="card card-content tags-widget">
    <div class="tags-card">
  <div class="tags-header">
    <i 
      class="iconfont icon-biaoqian" 
      style="padding-right: 2px;">
    </i>热门标签
  </div>
  <div class="tags-list">
    
      <a 
        href="/fungloengblog/tags/ubuntu/" 
        title="ubuntu">
        <div class="tags-list-item">ubuntu</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/docker/" 
        title="docker">
        <div class="tags-list-item">docker</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/openresty/" 
        title="openresty">
        <div class="tags-list-item">openresty</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/wsl2/" 
        title="wsl2">
        <div class="tags-list-item">wsl2</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/win10/" 
        title="win10">
        <div class="tags-list-item">win10</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/lua/" 
        title="lua">
        <div class="tags-list-item">lua</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/java/" 
        title="java">
        <div class="tags-list-item">java</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/canal/" 
        title="canal">
        <div class="tags-list-item">canal</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/MySQL/" 
        title="MySQL">
        <div class="tags-list-item">MySQL</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/wsl/" 
        title="wsl">
        <div class="tags-list-item">wsl</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/port/" 
        title="port">
        <div class="tags-list-item">port</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/hyper-v/" 
        title="hyper-v">
        <div class="tags-list-item">hyper-v</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/wsl1/" 
        title="wsl1">
        <div class="tags-list-item">wsl1</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/windows10/" 
        title="windows10">
        <div class="tags-list-item">windows10</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/gui/" 
        title="gui">
        <div class="tags-list-item">gui</div>
      </a>
    
      <a 
        href="/fungloengblog/tags/nginx/" 
        title="nginx">
        <div class="tags-list-item">nginx</div>
      </a>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
            <aside class="right-column">
              <div class="sticky-widescreen">
  
  
    <article class="card card-content toc-card">
      <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95-%E5%B9%B6%E5%9C%A8%E8%AF%A5%E7%9B%AE%E5%BD%95%E4%B8%8B%E5%88%9B%E5%BB%BAupdate-content-lua%E6%96%87%E4%BB%B6%EF%BC%8C%E7%9B%AE%E7%9A%84%E6%98%AF%E8%BF%9E%E6%8E%A5mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%AD%98%E5%82%A8%E5%88%B0redis%E4%B8%AD"><span class="toc-text">1. 创建目录,并在该目录下创建update_content.lua文件，目的是连接mysql数据库查询数据并存储到redis中</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2-%E4%BF%AE%E6%94%B9-usr-local-openresty-nginx-conf-nginx-conf%E6%96%87%E4%BB%B6%EF%BC%8C%E6%B7%BB%E5%8A%A0%E5%A4%B4%E4%BF%A1%E6%81%AF%E5%92%8Clocation%E4%BF%A1%E6%81%AF"><span class="toc-text">2. 修改&#x2F;usr&#x2F;local&#x2F;openresty&#x2F;nginx&#x2F;conf&#x2F;nginx.conf文件，添加头信息和location信息</span></a></li></ol>
    </article>
  
  
  <article class="card card-content">
    <div class="recent-posts-card">
  <div class="recent-posts-header">
    <i 
      class="iconfont icon-wenzhang_huaban" 
      style="padding-right: 2px;">
    </i>最近文章
  </div>
  <div class="recent-posts-list">
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-21</div>
        <a href="/fungloengblog/2021/12/21/centos7%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2/"><div class="recent-posts-item-content">centos7搭建博客</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-21</div>
        <a href="/fungloengblog/2021/12/21/centos7%E5%8F%96%E6%B6%88%E8%87%AA%E5%8A%A8%E4%BC%91%E7%9C%A0/"><div class="recent-posts-item-content"></div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-21</div>
        <a href="/fungloengblog/2021/12/21/centos7%E5%AE%89%E8%A3%85docker/"><div class="recent-posts-item-content"></div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-21</div>
        <a href="/fungloengblog/2021/12/21/docker%E5%AE%89%E8%A3%85jenkins/"><div class="recent-posts-item-content"></div></a>
      </div>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
          </div>
        </div>
      </div>
    </div>
     
    <footer class="footer">
  <div class="footer-container">
    <div>
      <div class="footer-dsc">
        <span>
          Copyright ©
          
            2020 -
          
          2021
        </span>
        &nbsp;
        <a 
          href="/fungloengblog/" 
          class="footer-link">
          FUNGLOENG
        </a>
      </div>
    </div>

    
      <div class="footer-dsc">
        
          Powered by
          <a 
            href="https://hexo.io/" 
            class="footer-link" 
            target="_blank" 
            rel="nofollow noopener noreferrer">
            &nbsp;Hexo
          </a>
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          Theme -
          <a 
            href="https://github.com/theme-kaze" 
            class="footer-link" 
            target="_blank"
            rel="nofollow noopener noreferrer">
            &nbsp;Kaze
          </a>
        
      </div>
    
    
    
    
      <div class="footer-dsc">
        
          本站总访问量<span id="busuanzi_value_site_pv"></span>次
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          本站总访客数<span id="busuanzi_value_site_uv"></span>次
        
      </div>
      
    
</footer> 
    
  <a 
    role="button" 
    id="scrollbutton" 
    class="basebutton" 
    aria-label="回到顶部">
    <i class="iconfont icon-arrowleft button-icon"></i>
  </a>

<a 
  role="button" 
  id="menubutton"
  aria-label="menu button"
  class="basebutton">
  <i class="iconfont icon-menu button-icon"></i>
</a>
<a 
  role="button" 
  id="popbutton" 
  class="basebutton" 
  aria-label="控制中心">
  <i class="iconfont icon-expand button-icon"></i>
</a>
<a 
  role="button" 
  id="darkbutton" 
  class="basebutton darkwidget" 
  aria-label="夜色模式">
  <i class="iconfont icon-weather button-icon"></i>
</a>
<a 
  role="button" 
  id="searchbutton" 
  class="basebutton searchwidget" 
  aria-label="搜索">
  <i class="iconfont icon-search button-icon"></i>
</a> 
     
     
     
      <script>
  var addImgLayout = function () {
    var img = document.querySelectorAll('.post-content img')
    var i
    for (i = 0; i < img.length; i++) {
      var wrapper = document.createElement('a')
      wrapper.setAttribute('href', img[i].getAttribute('data-src'))
      wrapper.setAttribute('aria-label', 'illustration')
      wrapper.style.cssText =
        'width: 100%; display: flex; justify-content: center;'
      if (img[i].alt) wrapper.dataset.caption = img[i].alt
      wrapper.dataset.nolink = true
      img[i].before(wrapper)
      wrapper.append(img[i])
      var divWrap = document.createElement('div')
      divWrap.classList.add('gallery')
      wrapper.before(divWrap)
      divWrap.append(wrapper)
    }
    baguetteBox.run('.gallery')
  }
</script>
<script>
  loadScript(
    "/fungloengblog/js/lib/lightbox/baguetteBox.min.js",
    addImgLayout
  )
</script>
 
     
     
    <script src="/fungloengblog/js/main.js"></script> 
    
      <script> 
        loadScript('/fungloengblog/js/lib/busuanzi.min.js') 
      </script>
     
    
      <script>
        var addLazyload = function () {
          var observer = lozad('.lozad', {
            load: function (el) {
              el.srcset = el.getAttribute('data-src')
            },
            loaded: function (el) {
              el.classList.add('loaded')
            },
          })
          observer.observe()
        }
      </script>
      <script>
        loadScript('/fungloengblog/js/lib/lozad.min.js', addLazyload)
      </script>
     
    
    
  </body>
</html>
